package com.wyz.easyexcel.handler;

import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.write.handler.CellWriteHandler;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteTableHolder;
import com.wyz.easyexcel.util.MessageStoreUtils;
import org.apache.poi.ss.usermodel.Row;

import java.util.List;

/**
 * @author wyz
 * @description: i18n 处理器
 * @date 2021/12/29 16:20
 */
public class I18nCellWriteHandler implements CellWriteHandler {

    @Override
    public void beforeCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row, Head head, Integer columnIndex, Integer relativeRowIndex, Boolean isHead) {

        for (int i = 0; i < head.getHeadNameList().size(); i++) {
            //国际化处理
            String message = MessageStoreUtils.getMessage(head.getHeadNameList().get(i));
            head.getHeadNameList().set(i,message);
        }
    }
}
